package com.xxgc.demo.controller.interceptor;

import com.xxgc.demo.controller.annotations.CheckIdCardDate;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: SJY
 * @Date :2023/9/11 - 09 - 11 - 10:47
 * 用于身份证日期信息的拦截器
 */
public class CheckIdCardDateInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        /**----------TODO 流只能读一次 怎么判断--------------------------**/
        if (handler instanceof HandlerMethod) {
            CheckIdCardDate checkDate = ((HandlerMethod) handler).getMethodAnnotation(CheckIdCardDate.class);
            if (checkDate != null) {//如果不为空证明包含了这个注解
                //ServletInputStream inputStream = request.getInputStream();
                //如果想要实现请复写 request.getInputStream();方法
            }
        }
        return true;
    }
}
